let upload;
layui.define(['form', 'layedit', 'laydate', 'upload', 'admin', 'formSelects'], function () {
    window.$ = layui.$;
    let form = layui.form;
    let layer = layui.layer;
    let admin = layui.admin;
    let formSelects = layui.formSelects;


    // 表单初始值
    form.val("zmn-supplier-form", json.items);

    zmnLayUtil.layFormVerify(form, {
        extend: {
            statusRadio: function (value, item) {
                let status = $("input[name='status']:checked").val();
                if (!status) {
                    return "状态不能为空";
                }
            }
        }
    });

    // 表单提交
    form.on('submit(save)', function (obj) {
        let data = {pertainCompanyIds: formSelects.value('useCompanyId', 'val'), supplier: obj.field};
        console.log(data);
        // console.log(formSelects.value('useCompanyId', 'val'));
        zmnLayUtil.ajaxResultDTOJson(parent.layer, "/supplier/ajax/addEdit.action", data, 0, function () {
            admin.events.closeThisTabs();
        }, function (data) {
        });

        return false;
    });


    $("#cancel").on("click", function (e) {
        zmnLayUtil.closeThisTabs();
    });


    // let renderCompanyDetail = function(companyId){
    //     if (!zmnUtil.isEmptyNull(companyId)){
    //         $("#company-detail-div").html('<a href="" style="color: #01AAED" lay-filter="company-detail" id="company-detail">查看公司信息</a>');
    //     } else {
    //         $("#company-detail-div").html('');
    //     }
    // }
    // renderCompanyDetail($("#companyId").val());
    // form.on('select(companyId)', function(data){
    //     let companyId = data.value;
    //     console.log(companyId);
    //     renderCompanyDetail(companyId);
    // });
    //
    // $(".layui-card").on("click","#company-detail",function (e) {
    //     let companyId = $("#companyId").val();
    //     zmnLayUtil.openIframe(parent.layui.layer,"公司信息"+companyId,"/company/detail.action?companyId="+companyId,null);
    //     return false;
    // });


});